package com.future.ssm.listener;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
 * 测试Servlet监听器
 *
 * @author shiyong
 * 2021/1/27 18:03
 */
public class MyListener implements ServletContextListener {

    /**
     * Receives notification that the web application initialization
     * process is starting.
     *
     * <p>All ServletContextListeners are notified of context
     * initialization before any filters or servlets in the web
     * application are initialized.
     *
     * @param sce the ServletContextEvent containing the ServletContext
     *            that is being initialized
     * @implSpec The default implementation takes no action.
     */
    @Override
    public void contextInitialized(ServletContextEvent sce) {
        System.out.println("Start...");
        System.out.println("服务启动...");
    }

    /**
     * Receives notification that the ServletContext is about to be
     * shut down.
     *
     * <p>All servlets and filters will have been destroyed before any
     * ServletContextListeners are notified of context
     * destruction.
     *
     * @param sce the ServletContextEvent containing the ServletContext
     *            that is being destroyed
     * @implSpec The default implementation takes no action.
     */
    @Override
    public void contextDestroyed(ServletContextEvent sce) {
        System.out.println("Shutdown...");
        System.out.println("服务关闭...");
    }
}
